public class Target {
    int[] nums = new int[]{2,7,11,15};
    //int[] nums = new int[]{2,8,7,15};
    int target = 9;
    
    public int[] findtarget(int[] nums,int target) {
        int[] ret = {0,0};//返回结果
        for (int i = 0; i < nums.length; i++) {
            int temp1 = target-nums[i];//接收判断第一个元素的位置
                for (int j = i+1; j < nums.length; j++) {
                    int temp2 = temp1 -nums[j];//接收判断第二个元素的位置
                    if (temp2 == 0) {
                        ret[0]=i;
                        ret[1]=j;
                        return ret;
                    }
            }
        }
        return ret;
    }
    
    public static void main(String[] args) {
        Target T1 = new Target();
        int[] ret = T1.findtarget(T1.nums, T1.target);
        for (int i = 0; i < ret.length; i++) {
            System.out.println(ret[i]);
        }
    }
}